home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / MemoryClassTest.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  2.5 KB  |  73 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1993 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Programmer: Kent Sandvik
  5.   Date: 1/2/93
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TMemory is a simple object checks heap and stack values, as well as changes them.
  9.   TMemoryClassTest.cp contains the TMemory class test functions.
  10.   _________________________________________________________________________________________________________ */
  11.  
  12.  
  13. #ifndef _MEMORYCLASS_
  14. #include "MemoryClass.h"
  15. #endif
  16.  
  17. // CONSTANTS
  18. const long kMyMinHeap = 200 * 1024;
  19. const long kMyMinStack = 60 * 1024;
  20.  
  21. // We will test out various stack and heap sizes. It is recommended to make a separate
  22. // application (SIOW or something similar) for testing this out. Don't forget to add the
  23. // special kStackResource -- the test program needs this one.
  24.  
  25. void main(void)
  26. {
  27.     cout << "Start of the TMemory object test…\n";
  28.  
  29.     // Create a TMemory object.    
  30.     TMemory myMemory(kMyMinHeap, kMyMinStack);
  31.  
  32.     // Check out current sizes.
  33.     cout << "Current Stack size is = " << myMemory.GetStackSize() << '\n';
  34.     cout << "Current Heap size is = " << myMemory.GetHeapSize() << '\n';
  35.  
  36.     // Change stack size.
  37.     cout << "I'm changing the stack size to 60k \n";
  38.     myMemory.SetStackSize(60 * 1024);
  39.     cout << "New Stack size is = " << myMemory.GetStackSize() << '\n';
  40.     cout << "I'm increasing the stack size by 10k \n";
  41.     myMemory.IncreaseStackSize(10 * 1024);
  42.     cout << "New Stack size is = " << myMemory.GetStackSize() << '\n';
  43.     cout << "Current Heap size is = " << myMemory.GetHeapSize() << '\n';
  44.  
  45.     // Check heap size values, valid?
  46.     if (myMemory.CheckHeapSize())
  47.         cout << "OK with the heap size, > 200k\n";
  48.     else
  49.         cout << "Problems with the heap size, < 200k\n";
  50.  
  51.     // Check stack size values, valid?
  52.     if (myMemory.CheckStackSize())
  53.         cout << "OK with the stack size, > 60k\n";
  54.     else
  55.         cout << "Problems with the stack size, < 60k\n";
  56.  
  57.     // Test of resource handling
  58.     if (myMemory.SetStackSizeFromResources())
  59.         cout << "OK with setting the stack size from resources, stack size = " << myMemory.GetStackSize() << '\n';
  60.     else
  61.         cout << "No resources, couldn't set stack size from a resource value\n";
  62.  
  63.     cout << "End of the TMemory object test!\n";
  64. }
  65.  
  66. // _________________________________________________________________________________________________________ //
  67.  
  68. /*    Change History (most recent last):
  69.   No        Init.    Date        Comment
  70.   1            khs        1/2/93        New file
  71.   2            khs        1/3/93        Cleanup
  72. */
  73.